import { createRouter, createWebHistory } from 'vue-router'
import PageView from '@/components/PageView.vue'

const routes = [
  {
    path: "/",
      redirect:{
        name: 'home'
      }
  
  },
  {
    path: "/login",
    name: "login",
    component: () => import('@/view/login/Login.vue')
  },
  {
    path: "/home",
    component: PageView,
    children: [
      {
        path: '',
        name: 'home',
        component: () => import('@/view/home/Home.vue'),
        meta: {
          title: '可视化图形界面'
        }
      },
    ]
  },
  {
    path: "/park",
    component: PageView,
    children: [
      {
        path: '',
        redirect: {
          name: 'building'
        }
      }, 
      {
        path: 'building',
        name: 'building',
        component: () => import('@/view/park/Building.vue'),
        meta: {
          title: '楼宇界面'
        }
      },
      {
        path: 'person',
        name: 'person',
        component: () => import('@/view/park/Person.vue'),
        meta: {
          title: '车辆界面'
        }
      },
    ]
  },
  {
    path: "/car",
    component: PageView,
    children: [
      {
        path: '',
        redirect: {
          name: 'carMonth'
        }
      }, 
      {
        path: 'carMonth',
        name: 'carMonth',
        component: () => import('@/view/car/CarArea.vue'),
        meta: {
          title: '本校车辆'
        }
      },
      {
        path: 'carRule',
        name: 'carRule',
        component: () => import('@/view/car/CarRules.vue'),
        meta: {
          title: '外来车辆'
        }
      },
    ]
  },
  {
    path: "/role",
    component: PageView,
    children: [
      {
        path: '',
        redirect: {
          name: 'part'
        }
      }, 
      {
        path: 'part',
        name: 'part',
        component: () => import('@/view/manage/partManage.vue'),
        meta: {
          title: '部门管理'
        }
      },
      {
        path: 'addPart',
        name: 'addPart',
        component: () => import('@/view/manage/components/AddPart.vue')
      },
      {
        path: 'employee',
        name: 'employee',
        component: () => import('@/view/manage/EmployeeManage.vue'),
        meta: {
          title: '员工管理'
        }
      },
    ]
  },
  {
    path: '/:pathMatch(.*)*',
    component: () => import('@/view/404/404.vue'),
    hidden: true
  }
]

// 创建路由实例
const router = createRouter({
  history: createWebHistory(),
  routes,
})
// 重置路由方法
export const resetRouter = () => {
  router.replace({
    path: '/login'
  })
}

export default router